package com.seata.demo;

import org.apache.commons.lang3.StringUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
* @comments
* @author  zg
* @date 2021年2月9日
*/
@Slf4j
@EnableAutoDataSourceProxy
@EnableFeignClients
@MapperScan("com.seata.demo.mapper")
@SpringBootApplication(scanBasePackages = "com.seata.demo")
public class SeataDemoOrderApplication {

    public static void main(String[] args) {
        //SpringApplication.run(SeataDemoOrderApplication.class, args);
        SpringApplication app = new SpringApplication(SeataDemoOrderApplication.class);
        Environment env = app.run(args).getEnvironment();
        log.info("【订单服务】SeataDemoOrderApplication starting......");
        logApplicationStartup(env);
    }

    private static void logApplicationStartup(Environment env) {
        String serverPort = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path");
        contextPath = StringUtils.isBlank(contextPath) ? "/doc.html" : contextPath + "/doc.html";
        log.info("\n----------------------------------------------------------" +
                "\n接口文档访问地址：\nhttp://localhost:{}{}", serverPort, contextPath);
    }
}
